<template>
  <div class="tech-exchange">
    <div class="section-header">
      <h3>
        <i class="fas fa-graduation-cap"></i>
        <span>技术交流</span>
      </h3>
      <NuxtLink to="/tech-exchange" class="more-link">
        <span>更多内容</span>
        <i class="fas fa-angle-double-right"></i>
      </NuxtLink>
    </div>

    <div class="tech-grid">
      <!-- 视频教程 -->
      <div class="tech-card">
        <div class="card-image">
          <img src="/images/academy-1.jpg" alt="香菇菌种培育技术精讲" />
          <div class="type-badge video">
            <i class="fas fa-video"></i>
            <span>视频教程</span>
          </div>
          <div class="play-overlay">
            <i class="fas fa-play-circle"></i>
          </div>
        </div>
        <div class="card-content">
          <h4 class="tech-title">香菇菌种培育技术精讲</h4>
          <p class="expert-info">李教授·农业专家</p>
          <div class="tech-tags">
            <span class="tag">菌种培育</span>
            <span class="tag">技术指导</span>
          </div>
          <div class="engagement-metrics">
            <div class="metric-item">
              <i class="fas fa-eye"></i>
              <span>12.5k</span>
            </div>
            <div class="metric-item">
              <i class="fas fa-clock"></i>
              <span>45分钟</span>
            </div>
            <div class="metric-item">
              <i class="fas fa-star"></i>
              <span>4.8</span>
            </div>
          </div>
        </div>
      </div>

      <!-- 技术文档 -->
      <div class="tech-card">
        <div class="card-image">
          <img src="/images/academy-2.jpg" alt="食用菌病虫害防治指南" />
          <div class="type-badge document">
            <i class="fas fa-file-alt"></i>
            <span>技术文档</span>
          </div>
          <div class="download-overlay">
            <i class="fas fa-download"></i>
          </div>
        </div>
        <div class="card-content">
          <h4 class="tech-title">食用菌病虫害防治指南</h4>
          <p class="expert-info">王工程师·植保专家</p>
          <div class="tech-tags">
            <span class="tag">病虫害</span>
            <span class="tag">防治技术</span>
          </div>
          <div class="engagement-metrics">
            <div class="metric-item">
              <i class="fas fa-download"></i>
              <span>8.2k</span>
            </div>
            <div class="metric-item">
              <i class="fas fa-file-pdf"></i>
              <span>PDF</span>
            </div>
            <div class="metric-item">
              <i class="fas fa-star"></i>
              <span>4.6</span>
            </div>
          </div>
        </div>
      </div>

      <!-- 专题讲座 -->
      <div class="tech-card">
        <div class="card-image">
          <img src="/images/academy-3.jpg" alt="黑木耳高产栽培技术" />
          <div class="type-badge lecture">
            <i class="fas fa-chalkboard-teacher"></i>
            <span>专题讲座</span>
          </div>
          <div class="live-overlay">
            <i class="fas fa-broadcast-tower"></i>
          </div>
        </div>
        <div class="card-content">
          <h4 class="tech-title">黑木耳高产栽培技术</h4>
          <p class="expert-info">张主任·种植专家</p>
          <div class="tech-tags">
            <span class="tag">高产栽培</span>
            <span class="tag">黑木耳</span>
          </div>
          <div class="engagement-metrics">
            <div class="metric-item">
              <i class="fas fa-calendar-alt"></i>
              <span>11-20</span>
            </div>
            <div class="metric-item">
              <i class="fas fa-users"></i>
              <span>560人</span>
            </div>
            <div class="metric-item">
              <i class="fas fa-star"></i>
              <span>4.9</span>
            </div>
          </div>
        </div>
      </div>

      <!-- 在线课程 -->
      <div class="tech-card">
        <div class="card-image">
          <img src="/images/academy-4.jpg" alt="智慧菌菇种植系统应用" />
          <div class="type-badge course">
            <i class="fas fa-laptop"></i>
            <span>在线课程</span>
          </div>
          <div class="course-overlay">
            <i class="fas fa-graduation-cap"></i>
          </div>
        </div>
        <div class="card-content">
          <h4 class="tech-title">智慧菌菇种植系统应用</h4>
          <p class="expert-info">刘老师·技术顾问</p>
          <div class="tech-tags">
            <span class="tag">智慧种植</span>
            <span class="tag">系统应用</span>
          </div>
          <div class="engagement-metrics">
            <div class="metric-item">
              <i class="fas fa-star"></i>
              <span>4.9分</span>
            </div>
            <div class="metric-item">
              <i class="fas fa-play-circle"></i>
              <span>12课时</span>
            </div>
            <div class="metric-item">
              <i class="fas fa-users"></i>
              <span>1.2k</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
// 技术交流数据
const techItems = ref([
  {
    id: 1,
    type: 'video',
    title: '香菇菌种培育技术精讲',
    expert: '李教授·农业专家',
    image: '/images/academy-1.jpg',
    metrics: [
      { icon: 'fas fa-eye', value: '12.5k' },
      { icon: 'fas fa-clock', value: '45分钟' }
    ]
  },
  {
    id: 2,
    type: 'document',
    title: '食用菌病虫害防治指南',
    expert: '王工程师·植保专家',
    image: '/images/academy-2.jpg',
    metrics: [
      { icon: 'fas fa-download', value: '8.2k' },
      { icon: 'fas fa-file-pdf', value: 'PDF' }
    ]
  },
  {
    id: 3,
    type: 'lecture',
    title: '黑木耳高产栽培技术',
    expert: '张主任·种植专家',
    image: '/images/academy-3.jpg',
    metrics: [
      { icon: 'fas fa-calendar-alt', value: '11-20' },
      { icon: 'fas fa-users', value: '560人' }
    ]
  },
  {
    id: 4,
    type: 'course',
    title: '智慧菌菇种植系统应用',
    expert: '刘老师·技术顾问',
    image: '/images/academy-4.jpg',
    metrics: [
      { icon: 'fas fa-star', value: '4.9分' },
      { icon: 'fas fa-play-circle', value: '12课时' }
    ]
  }
])

const getTypeInfo = (type) => {
  const types = {
    video: { label: '视频教程', icon: 'fas fa-video', color: '#e4393c' },
    document: { label: '技术文档', icon: 'fas fa-file-alt', color: '#52c41a' },
    lecture: { label: '专题讲座', icon: 'fas fa-chalkboard-teacher', color: '#1890ff' },
    course: { label: '在线课程', icon: 'fas fa-laptop', color: '#fa8c16' }
  }
  return types[type] || types.video
}
</script>

<style lang="scss" scoped>
.tech-exchange {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 16px;

  .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;

    h3 {
      display: flex;
      align-items: center;
      gap: 8px;
      margin: 0;
      font-size: 20px;
      font-weight: 600;
      color: #333;

      i {
        color: #e4393c;
        font-size: 22px;
      }
    }

    .more-link {
      display: flex;
      align-items: center;
      gap: 6px;
      color: #666;
      font-size: 14px;
      text-decoration: none;
      transition: all 0.3s;

      &:hover {
        color: #e4393c;
      }
    }
  }

  .tech-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;

    @include tablet {
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
    }

    @include mobile {
      grid-template-columns: 1fr;
      gap: 12px;
    }

    .tech-card {
      background: #fff;
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      transition: all 0.3s ease;
      cursor: pointer;
      height: 280px;
      display: flex;
      flex-direction: column;

      @include tablet {
        height: 260px;
      }

      @include mobile {
        height: 240px;
      }

      &:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
      }

      .card-image {
        position: relative;
        height: 140px;
        overflow: hidden;
        flex-shrink: 0;

        img {
          width: 100%;
          height: 100%;
          object-fit: cover;
          transition: transform 0.3s ease;
        }

        &:hover img {
          transform: scale(1.05);
        }

        .type-badge {
          position: absolute;
          top: 8px;
          left: 8px;
          display: inline-flex;
          align-items: center;
          gap: 4px;
          padding: 4px 8px;
          border-radius: 4px;
          font-size: 12px;
          font-weight: 600;
          color: #fff;
          z-index: 2;
          background: rgba(228, 57, 60, 0.9);
          backdrop-filter: blur(4px);

          i {
            font-size: 11px;
          }
        }

        .play-overlay,
        .download-overlay,
        .live-overlay,
        .course-overlay {
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          width: 40px;
          height: 40px;
          background: rgba(0, 0, 0, 0.6);
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          color: #fff;
          font-size: 16px;
          opacity: 0;
          transition: all 0.3s ease;
        }

        &:hover .play-overlay,
        &:hover .download-overlay,
        &:hover .live-overlay,
        &:hover .course-overlay {
          opacity: 1;
        }
      }

      .card-content {
        padding: 12px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;

        .tech-title {
          margin: 0 0 10px;
          font-size: 16px;
          font-weight: 600;
          color: #333;
          line-height: 1.4;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
        }

        .expert-info {
          margin: 0 0 15px;
          font-size: 14px;
          color: #666;
          line-height: 1.5;
          display: -webkit-box;
          -webkit-line-clamp: 3;
          -webkit-box-orient: vertical;
          overflow: hidden;
        }

        .tech-tags {
          margin: 0 0 10px;
          display: flex;
          gap: 4px;
          flex-wrap: wrap;

          .tag {
            padding: 2px 6px;
            background: #f0f0f0;
            color: #666;
            font-size: 10px;
            border-radius: 3px;
            line-height: 1.2;
          }
        }

        .engagement-metrics {
          display: flex;
          justify-content: space-between;
          align-items: center;
          font-size: 12px;
          color: #999;
          margin-top: auto;

          .metric-item {
            display: flex;
            align-items: center;
            gap: 4px;

            i {
              font-size: 11px;
            }
          }
        }
      }
    }
  }
}

// 动画效果
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tech-exchange {
  animation: fadeInUp 0.8s ease-out;
}
</style>
